package com.slz3.business.module.versions;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

@Component
@Order(0)
public class VersionsHandler {

    @Autowired
    private VersionsProperties prop;

    public Mono<ServerResponse> number(ServerRequest req) {
        ResInfo resInfo = RR.initReqResInfo(req);
        req.attributes().put(RR.RES_INFO, resInfo);
        return RR.success(req, ResInfo.builder().description(this.prop.getVersion()).build());
    }

}
